/* eslint-disable */
export const buildURLWithParams = (url, obj) => {
  const params = new URLSearchParams(obj);
  const queryParams = params.toString();
  return `${url}?${queryParams}`;
};

export const generateVerificationCode = () => {
  const min = 100000; // 最小值（六位数最小值为 100000）
  const max = 999999; // 最大值（六位数最大值为 999999）
  const verificationCode = Math.floor(Math.random() * (max - min + 1)) + min;
  return verificationCode;
};
// import cloneDeep from "lodash/cloneDeep";
// watch: {
//   $route(to, from) {
//     console.log("路由发生了变化：", to);
//     this.contact = cloneDeep(to.query);
//     this.contact.default = this.contact.default === "true" ? true : false;
//     // console.log("contact", contact);
//   },
// },
// 存储数据到 localStorage
export const saveLocal = (key, value) => {
  localStorage.setItem(key, JSON.stringify(value));
};

// 从 localStorage 中获取数据
export const getLocal = (key) => {
  const value = localStorage.getItem(key);
  return value ? JSON.parse(value) : null;
};

export const formatDate = (date) => {
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, "0");
  const day = String(date.getDate()).padStart(2, "0");
  const hours = String(date.getHours()).padStart(2, "0");
  const minutes = String(date.getMinutes()).padStart(2, "0");
  const seconds = String(date.getSeconds()).padStart(2, "0");

  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
